{% extends 'master.html' %}
<!DOCTYPE html>
{% block master %}
{% csrf_token %}
<div class="x-nav">
	<span class="layui-breadcrumb">
        <a href="">知识共享</a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
      </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-input-inline layui-show-xs-block">
                            <input type="text" id="id_name" name="name" placeholder="文章名称" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <select class="container" id="id_article_type">
                                <option value="">文章类型</option>
                                {% for item in article_type %}
                                    <option value="{{ item.id }}">{{ item.article_type_name }}</option>
                                {% endfor %}
                            </select>
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <select class="container" id="id_article_status">
                                <option value="">文章状态</option>
                                <option value="0">新建</option>
                                <option value="1">发布</option>
                                <option value="2">撤回</option>
                            </select>
                        </div>
                    </form>
                    <div class="layui-input-inline layui-show-xs-block UserTable">
                        <button class="layui-btn" lay-submit="" lay-filter="sreach" data-type="reload">
                            <i class="layui-icon">&#xe615;</i></button>
                    </div>
                </div>
                <xblock>
                    <div class="layui-card-header UserTable">
                        <button type="button" class="layui-btn" onclick="x_admin_show('创建文章', '{% url 'articlecreate' %}')">
                            <i class="layui-icon layui-icon-ok"></i>添加文章
                        </button>
                    </div>
                </xblock>
                <!-- user table-->
                <div class="layui-card-body">
                    <table class="layui-table layui-form" id="article_table"></table>
                </div>
                <!--end user table-->
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
var csrf = $('input[name="csrfmiddlewaretoken"]').val();
layui.use('table', function(){
    var table = layui.table;
    //方法级渲染
    table.render({
        elem: '#article_table'
        ,url: "{% url 'articlelist' %}"
        ,method: 'post'
        ,where: {'csrfmiddlewaretoken':csrf}
        ,cols: [[
            {checkbox: true, fixed: true}
            ,{field: 'article_name', title: '文章标题', sort: true, fixed: true,event:'article'}
            ,{field: 'article_type', title: '文章类型'}
            ,{field: 'updatetime', title: '更新时间', sort: true}
            ,{field: 'article_status', title: '文章状态', sort: true}
            ,{field: 'article_user', title: '文章作者'}
            ,{ title: '高级选项',fixed: 'right', align:'center', toolbar: '#barDemo'}
        ]]
        ,id: 'testReload'
        ,page: true
        ,limit: 15
        ,text:{none: '目前暂无数据'}
    });
});
</script>
{% endblock %}